home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / mfb / RCS / mfbhrzvert.c,v < prev    next >
Encoding:
Text File  |  1990-02-15  |  4.2 KB  |  177 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     90.02.14.19.58.08;  author tve;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @Original X11R4 distribution
  17. @
  18.  
  19.  
  20.  
  21. 1.1
  22. log
  23. @Initial revision
  24. @
  25. text
  26. @/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
  27. /***********************************************************
  28. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  29. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  30.  
  31.                         All Rights Reserved
  32.  
  33. Permission to use, copy, modify, and distribute this software and its 
  34. documentation for any purpose and without fee is hereby granted, 
  35. provided that the above copyright notice appear in all copies and that
  36. both that copyright notice and this permission notice appear in 
  37. supporting documentation, and that the names of Digital or MIT not be
  38. used in advertising or publicity pertaining to distribution of the
  39. software without specific, written prior permission.  
  40.  
  41. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  42. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  43. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  44. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  45. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  46. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  47. SOFTWARE.
  48.  
  49. ******************************************************************/
  50. /* $XConsortium: mfbhrzvert.c,v 1.11 89/09/13 18:58:09 rws Exp $ */
  51. #include "X.h"
  52.  
  53. #include "gc.h"
  54. #include "window.h"
  55. #include "pixmap.h"
  56. #include "region.h"
  57.  
  58. #include "mfb.h"
  59. #include "maskbits.h"
  60.  
  61. /* horizontal solid line
  62.    abs(len) > 1
  63. */
  64. mfbHorzS(rop, addrl, nlwidth, x1, y1, len)
  65. int rop;        /* a reduced rasterop */
  66. register int *addrl;    /* pointer to base of bitmap */
  67. register int nlwidth;    /* width in longwords of bitmap */
  68. int x1;            /* initial point */ 
  69. int y1;
  70. int len;        /* length of line */
  71. {
  72.     register int startmask;
  73.     register int endmask;
  74.     register int nlmiddle;
  75.  
  76.  
  77.     /* force the line to go left to right
  78.        but don't draw the last point
  79.     */
  80.     if (len < 0)
  81.     {
  82.     x1 += len;
  83.     x1 += 1;
  84.     len = -len;
  85.     }
  86.  
  87.     addrl = addrl + (y1 * nlwidth) + (x1 >> 5);
  88.  
  89.     /* all bits inside same longword */
  90.     if ( ((x1 & 0x1f) + len) < 32)
  91.     {
  92.     maskpartialbits(x1, len, startmask);
  93.         if (rop == RROP_BLACK)
  94.         {
  95.         *addrl &= ~startmask;
  96.         }
  97.         else if (rop == RROP_WHITE)
  98.         {
  99.         *addrl |= startmask;
  100.         }
  101.         else if (rop == RROP_INVERT)
  102.         {
  103.         *addrl ^= startmask;
  104.         }
  105.     }
  106.     else
  107.     {
  108.     maskbits(x1, len, startmask, endmask, nlmiddle);
  109.         if (rop == RROP_BLACK)
  110.         {
  111.         if (startmask)
  112.         *addrl++ &= ~startmask;
  113.         Duff (nlmiddle, *addrl++ = 0x0);
  114.         if (endmask)
  115.         *addrl &= ~endmask;
  116.         }
  117.         else if (rop == RROP_WHITE)
  118.         {
  119.         if (startmask)
  120.         *addrl++ |= startmask;
  121.         Duff (nlmiddle, *addrl++ = 0xffffffff);
  122.         if (endmask)
  123.         *addrl |= endmask;
  124.         }
  125.         else if (rop == RROP_INVERT)
  126.         {
  127.         if (startmask)
  128.         *addrl++ ^= startmask;
  129.         Duff (nlmiddle, *addrl++ ^= 0xffffffff);
  130.         if (endmask)
  131.         *addrl ^= endmask;
  132.         }
  133.     }
  134. }
  135.  
  136. /* vertical solid line
  137.    this uses do loops because pcc (Ultrix 1.2, bsd 4.2) generates
  138.    better code.  sigh.  we know that len will never be 0 or 1, so
  139.    it's OK to use it.
  140. */
  141.  
  142. mfbVertS(rop, addrl, nlwidth, x1, y1, len)
  143. int rop;        /* a reduced rasterop */
  144. register int *addrl;    /* pointer to base of bitmap */
  145. register int nlwidth;    /* width in longwords of bitmap */
  146. int x1, y1;        /* initial point */
  147. register int len;    /* length of line */
  148. {
  149.     register int bitmask;
  150.  
  151.     addrl = addrl + (y1 * nlwidth) + (x1 >> 5);
  152.  
  153.     if (len < 0)
  154.     {
  155.     nlwidth = -nlwidth;
  156.     len = -len;
  157.     }
  158.  
  159.     if (rop == RROP_BLACK)
  160.     {
  161.     bitmask = rmask[x1&0x1f];
  162.         Duff(len, *addrl &= bitmask; addrl += nlwidth );
  163.     }
  164.     else if (rop == RROP_WHITE)
  165.     {
  166.     bitmask = mask[x1&0x1f];
  167.         Duff(len, *addrl |= bitmask; addrl += nlwidth );
  168.     }
  169.     else if (rop == RROP_INVERT)
  170.     {
  171.     bitmask = mask[x1&0x1f];
  172.         Duff(len, *addrl ^= bitmask; addrl += nlwidth );
  173.     }
  174. }
  175.  
  176. @
  177.